layui.config({
    base: '/static/js/lib/',
    version: new Date().getTime()
}).use(['layer', "table"], function () {

    $ = layui.jquery;
    var layer = layui.layer;
    var table = layui.table;
    var form = layui.form;


    form.on('submit(sreach)', function (data) {
        tableRender(data.field);
        return false;
    });

    function tableRender(queryCondition) {
        var url = "/audit/page?";
        for (var key in queryCondition) {
            url += (key + "=" + queryCondition[key] + "&");
        }
        url = url.substring(0, url.length - 1);
        table.render({
            elem: '#queslib-page',
            url: url,
            page: true,
            cols: [[
                {field: 'id', title: '单据ID', fixed: 'left'}
                , {field: 'shopId', title: '商铺ID'}
                , {field: 'shopName', title: '商户名称'}
                , {field: 'docType', title: '单据类型', templet: "#docTypeTempLet"}
                , {field: 'auditStatus', title: '单据状态', templet: "#auditStatusTempLet"}
                , {field: 'updateTime', title: '最后更新时间'}
                , {title: "操作", toolbar: '#funcBar'}
            ]]
        });
    }

    tableRender({});

    //监听工具条
    table.on('tool(queslib-page)', function (obj) {
        var data = obj.data;
        var layEvent = obj.event;
        if (layEvent == "autit") {
            layer.open({
                type: 2,
                area: ['100%', '100%'],
                fix: false,
                maxmin: true,
                shadeClose: true,
                shade: 0.4,
                title: "基本信息",
                content: "/audit/get/audit/doc?id=" + data.id
            });
        }
    });
});